/** \file config.h
 * \brief Basic configuration of the project
 * \author Freddie Chopin, http://www.freddiechopin.info/
 * \date 2012-03-17
 */

/******************************************************************************
* project: stm32f4_blink_led
* chip: STM32F407VG
* compiler: arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 4.6.2
* 	20110921 (release) [ARM/embedded-4_6-branch revision 182083]
******************************************************************************/

#ifndef CONFIG_H_
#define CONFIG_H_

#include "hdr_bitband.h"

/*
+=============================================================================+
| global definitions
+=============================================================================+
*/

#define CRYSTAL								8000000ul	///< quartz crystal resonator which is connected to the chip
#define FREQUENCY							168000000ul	///< desired target frequency of the core

#define LED_GPIO							GPIOD		///< GPIO port to which the LED is connected
#define ACC_GPIO							GPIOA
#define SD_GPIO								GPIOB
#define ACC_CS_GPIO							GPIOE
#define USART2_GPIO							GPIOD
#define USART1_GPIO							GPIOA


#define LED_pin								13			///< pin number of the LED

#define ACC_CS_pin							3
#define ACC_SCK_pin							5
#define ACC_MOSI_pin						7
#define ACC_MISO_pin						6

#define SD_CS_pin							12
#define SD_SCK_pin							13
#define SD_MOSI_pin							15
#define SD_MISO_pin							14

#define USART2_TX_pin						5
#define USART2_RX_pin						6

#define USART1_TX_pin						9
#define USART1_RX_pin						10


#define LED									(1 << LED_pin)
#define LED_ODR								LED_GPIO->ODR	///< output register for the LED
#define LED_bb								bitband_t m_BITBAND_PERIPH(&LED_ODR, LED_pin)	///< bit-band "variable" to directly handle the pin

#define SD_ODR								SD_GPIO->ODR	///< output register for the SPI2
#define SD_CS								(1 << SD_CS_pin)
#define SD_CS_bb							bitband_t m_BITBAND_PERIPH(&SD_ODR, SD_CS_pin)	///< bit-band "variable" to directly handle the pin
#define SD_SCK								(1 << SD_SCK_pin)
#define SD_SCK_bb							bitband_t m_BITBAND_PERIPH(&SD_ODR, SD_SCK_pin)	///< bit-band "variable" to directly handle the pin
#define SD_MISO								(1 << SD_MISO_pin)
#define SD_MISO_bb							bitband_t m_BITBAND_PERIPH(&SD_ODR, SD_MISO_pin)	///< bit-band "variable" to directly handle the pin
#define SD_MOSI								(1 << SD_MOSI_pin)
#define SD_MOSI_bb							bitband_t m_BITBAND_PERIPH(&SD_ODR, SD_MOSI_pin)	///< bit-band "variable" to directly handle the pin

#define ACC_CS_ODR							ACC_CS_GPIO->ODR
#define ACC_ODR								ACC_GPIO->ODR	///< output register for the CS accelerometer
#define ACC_CS								(1 << ACC_CS_pin)
#define ACC_CS_bb							bitband_t m_BITBAND_PERIPH(&ACC_CS_ODR, ACC_CS_pin)	///< bit-band "variable" to directly handle the pin
#define ACC_SCK								(1 << ACC_SCK_pin)
#define ACC_SCK_bb							bitband_t m_BITBAND_PERIPH(&ACC_ODR, ACC_SCK_pin)	///< bit-band "variable" to directly handle the pin
#define ACC_MISO							(1 << ACC_MISO_pin)
#define ACC_MISO_bb							bitband_t m_BITBAND_PERIPH(&ACC_ODR, ACC_MISO_pin)	///< bit-band "variable" to directly handle the pin
#define ACC_MOSI							(1 << ACC_MOSI_pin)
#define ACC_MOSI_bb							bitband_t m_BITBAND_PERIPH(&ACC_ODR, ACC_MOSI_pin)	///< bit-band "variable" to directly handle the pin

#define USART2_ODR							USART2_GPIO->ODR	///< output register for the USART2
#define USART2_TX							(1 << USART2_TX_pin)
#define USART2_TX_bb						bitband_t m_BITBAND_PERIPH(&USART2_ODR, USART2_TX_pin)	///< bit-band "variable" to directly handle the pin

#define USART2_RX							(1 << USART2_RX_pin)
#define USART2_RX_bb						bitband_t m_BITBAND_PERIPH(&USART2_ODR, USART2_RX_pin)	///< bit-band "variable" to directly handle the pin

#define USART1_ODR							USART1_GPIO->ODR	///< output register for the USART1
#define USART1_TX							(1 << USART1_TX_pin)
#define USART1_TX_bb						bitband_t m_BITBAND_PERIPH(&USART1_ODR, USART1_TX_pin)	///< bit-band "variable" to directly handle the pin

#define USART1_RX							(1 << USART1_RX_pin)
#define USART1_RX_bb						bitband_t m_BITBAND_PERIPH(&USART1_ODR, USART1_RX_pin)	///< bit-band "variable" to directly handle the pin

/*
+=============================================================================+
| strange variables
+=============================================================================+
*/

/*
+=============================================================================+
| global variables
+=============================================================================+
*/

/*
+=============================================================================+
| global functions' declarations
+=============================================================================+
*/

typedef signed char int8_t;
typedef unsigned char uint8_t;

/******************************************************************************
* END OF FILE
******************************************************************************/
#endif /* CONFIG_H_ */
